import types from '../../types'

export default {
  [types.SEARCH] (state, result) {
    // console.log(result)
    // state.data.pageNum = result.pageNumber
    // state.data.pages = result.totalPage
    // state.data.count = result.totalRow
    // state.data.list = state.data.list.concat(result.list)
    state.keyname = result.keyname
    state.keyword = result.keyword

    state.data = {
      ...state.data,
      count: result.totalRow,
      pageNum: result.pageNumber,
      // next: result.lastPage ? false : result.pageNumber + 1,
      next: !result.lastPage,
      list: state.data.list.concat(result.list)
    }
  },

  [types.SEARCH_RESET] (state) {
    state.data = {
      count: 0,
      pageNum: 1,
      pages: 0,
      next: true,
      loading: false,
      list: []
    }
  },

  [types.SEARCHING] (state, result) {
    // console.log('loading', result)
    state.data.loading = result
  },

  [types.SUB_LIBS] (state, result) {
    state.subLibs = result.ZONE
  }
}
